home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility1 / gs261src.zip / LPRSETUP.SH < prev    next >
Linux/UNIX/POSIX Shell Script  |  1993-05-07  |  5KB  |  187 lines

  1. #!/bin/sh
  2. #
  3. # BSD PRINT FILTER SETUP utility for Ghostscript - used and tested on
  4. # SunOS 4.1.3, but I hope it will be useful on other BSD systems
  5. # See documentation for usage
  6. #
  7.  
  8. DEVICES="cdj550.24.dq cdj550.16.dq cdj550.8.dq cdj550.3.dq cdj550.1.dq deskjet djet500.dq"
  9. #FILTERS="if nf tf gf vf df cf rf"
  10. FILTERS="if"
  11.  
  12. GSDIR=/usr/local/lib/ghostscript
  13. GSFILTERDIR=$GSDIR/filt
  14. SPOOLDIR=/var/spool
  15. GSIF=unix-lpr.sh
  16. PCAP=printcap.insert
  17.  
  18. PATH=/bin:/usr/bin:/usr/ucb
  19. export PATH
  20.  
  21. if [ ! -w $GSDIR ]; then
  22.   echo "$GSDIR must be writable to create filter directory"
  23.   exit 1
  24. fi
  25.  
  26. echo "
  27. Making links in the filter directory $GSFILTERDIR ...
  28. "
  29.  
  30. #
  31. # Make the directory for holding the filter and links
  32. #
  33. if [ -d $GSFILTERDIR ]; then
  34.   echo "$GSFILTERDIR already exists - not created"
  35. else
  36.   mkdir $GSFILTERDIR
  37. fi
  38. rm -f $GSFILTERDIR/direct
  39. ln -s . $GSFILTERDIR/direct
  40. rm -f $GSFILTERDIR/indirect
  41. ln -s . $GSFILTERDIR/indirect
  42.  
  43. #
  44. # Create a link from each filtertype to the real filter script
  45. #
  46. for filter in $FILTERS
  47. do
  48.   rm -f $GSFILTERDIR/gs$filter
  49.   ln -s  ../$GSIF $GSFILTERDIR/gs$filter
  50. done
  51.  
  52. #
  53. # Create a link from each device to the filter directory
  54. #
  55. for device in $DEVICES
  56. do
  57.   dualqueue=
  58.   case "$device" in
  59.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  60.   esac
  61.   rm -f $GSFILTERDIR/$device
  62.   if [ $dualqueue ]; then
  63.     rm -f $GSFILTERDIR/indirect/$device
  64.     ln -s . $GSFILTERDIR/indirect/$device
  65.   else
  66.     rm -f $GSFILTERDIR/direct/$device
  67.     ln -s . $GSFILTERDIR/direct/$device
  68.   fi
  69. done
  70.  
  71. #
  72. # Create a basic printcap insert - this is made in the CURRENT directory
  73. #
  74. rm -f $PCAP
  75. cat > $PCAP << EOF
  76. # This is an example printcap insert for Ghostscript printers
  77. # You will probably want either to change the names for each printer
  78. # below (first line for each device) to something more sensible, or
  79. # to add additional name entries (eg cdjcolor for cdj500.24)
  80. # The example is shown set up for serial printers - you will need
  81. # to alter the entries for a parallel or networked remote printer,
  82. # eg. a remote network printer would have a line something like:
  83. #    :lp=:rm=artemis:rp=LPT1:
  84. # for a PC called artemis, replacing the serial port settings
  85. #
  86. # NB/ This is only an example - it is unlikely to be complete or exactly
  87. # correct for your system, but is designed to illustrate filter names 
  88. # corresponding to the accompanying bsd-if print filter
  89. EOF
  90.  
  91. (
  92. previous=undefined
  93. for device in $DEVICES
  94. do
  95.   dualqueue=
  96.   case "$device" in
  97.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  98.   esac
  99.   case "$device" in
  100.     *.24) base=`basename $device .24` ;;
  101.     *.16) base=`basename $device .16` ;;
  102.     *.8)  base=`basename $device .8` ;;
  103.     *.3)  base=`basename $device .3` ;;
  104.     *.1)  base=`basename $device .1` ;;
  105.     *)    base=$device ;;
  106.   esac
  107. #
  108. # If device listed with '.dq' suffix, we set up a separate output queue
  109. #
  110.   if [ $dualqueue ]; then
  111.     if [ $base != $previous ]; then
  112.       previous=$base
  113.       echo "
  114. # Entry for raw device $base.raw
  115. $base.raw|Raw output device $base:\\
  116.     :lp=/dev/ttyb:br#19200:xc#0177777:\\
  117.     :ms=-parity,ixon,-opost:\\
  118.     :sd=$SPOOLDIR/$base/raw:\\
  119.     :mx#0:sf:sh:rs:"
  120.     fi
  121.     echo "
  122. # Entry for device $device (output to $base.raw)
  123. $device|Ghostscript device $device:\\
  124.     :lp=/dev/null:\\"
  125.   else
  126.     echo "
  127. # Entry for device $device
  128. $device|Ghostscript device $device:\\
  129.     :lp=/dev/ttyb:br#19200:xc#0177777:\\
  130.     :ms=-parity,ixon,-opost:\\"
  131.   fi
  132.   echo "\
  133.     :sd=$SPOOLDIR/$base:\\
  134.     :lf=$SPOOLDIR/$base/logfile:\\
  135.     :af=$SPOOLDIR/$base/acct:\\"
  136.   for filter in $FILTERS
  137.   do
  138.     if [ $dualqueue ]; then
  139.       echo "\
  140.     :$filter=$GSFILTERDIR/indirect/$device/gs$filter:\\"
  141.     else
  142.       echo "\
  143.     :$filter=$GSFILTERDIR/direct/$device/gs$filter:\\"
  144.     fi
  145.   done
  146.   echo "\
  147.     :mx#0:sf:sh:rs:"
  148. done
  149. ) >> $PCAP
  150.  
  151. echo "
  152. Example printcap insert file \"$PCAP\" now created"
  153.  
  154. #
  155. # Remind the user what's still to do
  156. #
  157.  
  158. echo "
  159. NB/ You will need to create the following directories, with
  160. appropriate permissions, and do 'touch logfile' and 'touch acct'
  161. in the top level directories (ie. not the 'raw' ones):
  162. "
  163. (
  164. for device in $DEVICES
  165. do
  166.   dualqueue=
  167.   case "$device" in
  168.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  169.   esac
  170.   case "$device" in
  171.     *.24) base=`basename $device .24` ;;
  172.     *.16) base=`basename $device .16` ;;
  173.     *.8)  base=`basename $device .8` ;;
  174.     *.3)  base=`basename $device .3` ;;
  175.     *.1)  base=`basename $device .1` ;;
  176.     *)    base=$device ;;
  177.   esac
  178.   echo "  $SPOOLDIR/$base"
  179.   if [ $dualqueue ]; then
  180.     echo "  $SPOOLDIR/$base/raw"
  181.   fi
  182. done
  183. ) | sort -u
  184.  
  185. echo "
  186.         + + + "
  187.